# !/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
===========================
@Time : 2022/8/19 0019 20:52
@Author : 测试开发工程师
@File : 3-http_request.hasattr_demo.py
@Software: PyCharm
============================
"""

from flask import Flask

# get 请求：
app = Flask(__name__)


# methods 是一个列表类型，可以添加多种 请求方式，get, post, put, delete

# 查询 get
@app.route('/case', methods=['get'])
def get_case():
    return {'code': 0, 'msg': 'get success'}


# 开启后 访问 http://127.0.0.1:5000/case
if __name__ == '__main__':
    app.run()


# 新增 post
@app.route('/testcase', methods=['post'])
def post_case():
    return {'code': 0, 'msg': 'post success'}


# 开启后 postman 访问  POST  http://127.0.0.1:5000/testcase
if __name__ == '__main__':
    app.run()


# 修改 put
@app.route('/testcase0', methods=['put'])
def put_case():
    return {'code': 0, 'msg': 'put success'}


# 开启后 postman 访问  PUT  http://127.0.0.1:5000/testcase0
if __name__ == '__main__':
    app.run()


# 删除 delete
@app.route('/testcase1', methods=['delete'])
def delete_case():
    return {'code': 0, 'msg': 'delete success'}


# 开启后 postman 访问  DELETE  http://127.0.0.1:5000/testcase1
if __name__ == '__main__':
    app.run()
